package com.caogt.user.userInfo.controller;


import com.caogt.common.restful.ResultData;
import com.caogt.user.userInfo.service.IUserInfoService;
import com.caogt.user.userInfo.entity.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author caogt
 * @since 2019-06-15
 */
@Controller
@RequestMapping("/userManager")
public class UserInfoController {

    @Autowired
    private IUserInfoService userInfoService;
    @ResponseBody
    @PostMapping("/save")
    public ResultData save(@RequestBody UserInfo userInfo){
        userInfoService.save(userInfo);
        return ResultData.success();
    }
    @ResponseBody
    @GetMapping("/query")
    public ResultData query(String name){
        return ResultData.success(userInfoService.query(name));
    }
    @ResponseBody
    @DeleteMapping("/{id}")
    public ResultData delete(Long id){
        boolean rest = userInfoService.removeById(id);
        ResultData resultData = new ResultData();
        resultData.setFlag(rest);
        return resultData;
    }
}
